package com.tech.connect.zhaofuwu;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.ksy.common.image.ImageLoader;
import com.ksy.common.utils.BaseAdapter;
import com.ksy.common.utils.BaseHolder;
import com.ksy.common.view.HLineDivider;
import com.tech.connect.R;
import com.tech.connect.activity.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class QuanZiYueDanListActivity extends BaseActivity {


    private RecyclerView recycler;
    private BaseAdapter<String, BaseHolder> adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getHeadBar().setTitle("服务约单");
        setContentView(R.layout.activity_comment_list);
        initView();
        loadData();
    }

    private void initView() {
        recycler = findViewById(R.id.recycler);
        recycler.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false));
        recycler.addItemDecoration(new HLineDivider());

    }

    private void initAdapter() {
        final List<String> allList = new ArrayList<>();
        if (adapter == null) {
            adapter = new BaseAdapter<String, BaseHolder>(R.layout.item_layout_yuedan_list, allList, 6) {
                @Override
                protected void convert(BaseHolder helper, int position) {
                    String item = allList.get(position);
                    ImageView ivHead = helper.getView(R.id.ivHead);
                    TextView tvName = helper.getView(R.id.tvName);
                    TextView tvInfo = helper.getView(R.id.tvInfo);
                    ImageLoader.getInstance().loadHead(activity, item, ivHead);
                    tvName.setText("约单");
                    tvInfo.setText("约单");
                }
            };
            recycler.setAdapter(adapter);
        }
        adapter.notifyDataSetChanged();
    }

    private void loadData() {
        initAdapter();
    }

}